package edu.scau.core.Enum;

public enum SaleLineItemStatus {
    normal("正常加购",0),
    book("缺货预定",1),
    Dispatch("完成出库",2),
    refunded("退货",3);
    private final String desc;
    private final int signal;

    SaleLineItemStatus(String desc, int signal) {
        this.desc=desc;
        this.signal=signal;
    }

    public String getDesc() {
        return desc;
    }

    public int getSignal(){
        return signal;
    }

    /**
     * 通过signal获取枚举常量
     * @param signal
     * @return
     */
    public static SaleLineItemStatus getBySignal(int signal) {
        for (SaleLineItemStatus status : SaleLineItemStatus.values()) {
            if (status.getSignal() == signal) {
                return status;
            }
        }
        throw new IllegalArgumentException("Invalid signal: " + signal);
    }
}
